package com.kfm.servlet.day02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;

@WebServlet("/req")
public class RequestServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(req);
//        System.out.println("method: " + req.getMethod());
//        System.out.println("URI: " + req.getRequestURI());
//        System.out.println("URL: " + req.getRequestURL());
//        System.out.println("protocol: " + req.getProtocol());
//        System.out.println("localPort: " + req.getLocalPort());
//        System.out.println("remotePort: " + req.getRemotePort());
//        System.out.println("servetPort: " + req.getServerPort());
//        System.out.println("remoteaddr: " + req.getRemoteAddr());

        System.out.println(req.getHeader("USER-AGENT"));
//        Enumeration<String> headerNames = req.getHeaderNames();
//
//        while (headerNames.hasMoreElements()) {
//            String name = headerNames.nextElement();
//            System.out.println(name + ": " + req.getHeader(name));
//        }
    }
}
